-- RewardAmazingBoxTipsView

local IconRender = require("app.widget.renders.IconRender")

local ClassRef = app.mvc.createPanelClass(...)

function ClassRef.create(node)
    local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.AmazingBoxTips))
    sprite:init()
    return sprite
end

function ClassRef:init(data)
    self.super.init(self, data)
    self:setContentSize(self._ui.Panel:getContentSize())
end

function ClassRef:refresh()
    if self._data then
        local data = self._data
        local conf = GD:getActivityAmazingAwardById(data.packageID)
        if conf then
            self._ui.tlt:setString(L(conf.name))
        end
        local dropId = data.dropID
        local drops = UD:parseDropIDToBagItem(dropId)
        for i = 1, 3 do
            local render = self._ui["Panel/Panel_"..i]
            if drops[i] then
                local icon = IconRender.create(render:getChildByName("icon"))
                icon:setTipEnable(true)
                icon:setData(drops[i])
                render:getChildByName("name"):setString(drops[i]:getName())
                render:getChildByName("text"):setString(drops[i]:getDesc())
                render:setVisible(true)
            else
                render:setVisible(false)
            end
        end
    end
end

return ClassRef